//
//  ProfileCoverView.m
//  MeToo
//
//  Created by 俊松何 on 2018/7/8.
//  Copyright © 2018年 tianxie. All rights reserved.
//

#import "ProfileCoverView.h"

@interface ProfileCoverView()
@property (weak, nonatomic) IBOutlet UILabel *fansnumLable;
@property (weak, nonatomic) IBOutlet UILabel *likenumLable;
@property (weak, nonatomic) IBOutlet UILabel *follownumLable;
@property (weak, nonatomic) IBOutlet UILabel *signatureLable;


@property (weak, nonatomic) IBOutlet UILabel *replaynumLable;




@end

@implementation ProfileCoverView
-(void)awakeFromNib
{   [super awakeFromNib];
    
    self.addfriendButton.hidden = YES;
    self.followopButton.hidden = YES;
    self.followopButton.titleLabel.adjustsFontSizeToFitWidth = YES;
//    [self.followopButton setTitle:NSLTLocalizedString(@"squareDetail.attension", @"关注") forState:UIControlStateNormal];
//    [self.followopButton setTitle:NSLTLocalizedString(@"squareDetail.attensioned", @"已关注") forState:UIControlStateSelected];
   
    
}

+(instancetype)profileCoverView
{
    NSBundle *bud = [NSBundle mainBundle];
    NSArray *arry = [bud loadNibNamed:NSStringFromClass(self) owner:nil options:nil];
    ProfileCoverView *view = arry.lastObject;
    view.frame = CGRectMake(0, 0,  WIDTH,  250);
    return view;
}

-(void)setUserModel:(MTUserModel *)userModel
{
    _userModel = userModel;
    self.fansnumLable.text = [NSString stringWithFormat:@"%ld", userModel.info.fansCnt];
    self.likenumLable.text = [NSString stringWithFormat:@"%ld", userModel.info.likeCnt];
    self.follownumLable.text = [NSString stringWithFormat:@"%ld", userModel.info.followCnt];
    self.replaynumLable.text = [NSString stringWithFormat:@"%ld", userModel.info.replayCnt];
    
    self.signatureLable.text = userModel.info.signature;
    if(userModel.info.signature.length == 0)
    {
        self.signatureLable.text = @"这个人很懒，什么也没有留下...";
    }
    [self.coverImageView sd_setImageWithURL:[NSURL URLWithString:userModel.info.cover] placeholderImage:[UIImage imageNamed:@"discover_cover"]];
    self.nameLable.text = userModel.name;
    [self.headerImageView sd_setImageWithURL:[NSURL URLWithString:userModel.avatar]];
    // 自己的广场不关注
    
    if ([userModel.info.userId isEqualToString:[LTClient sharedClient].currentUserId]) {
        self.followopButton.hidden = YES;
        self.addfriendButton.hidden = YES;
    }else
    {
        self.followopButton.hidden = NO;
    }
    if (userModel.follow) {
        ViewBorderRadius(self.followopButton, 4, 0.5, UIColorFromRGB(0xe6e6e6));
        self.followopButton.backgroundColor =UIColorFromRGB(0xf2f2f2);
        [self.followopButton setTitle:@"已关注" forState:UIControlStateNormal];
        [self.followopButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
    } else {
        ViewBorderRadius(self.followopButton, 4, 0.5, UIColorFromRGB(0xe6e6e6));
        self.followopButton.backgroundColor =UIColorFromRGB(0xf87e7e);
         [self.followopButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [self.followopButton setTitle:@"关注" forState:UIControlStateNormal];
    }
    
    if(![[[LTClient sharedClient] contactManager] isFriendWithUserId:userModel.userId] && ![[[LTClient sharedClient] contactManager] isMyselfWithUserId:userModel.userId])
    {
        self.addfriendButton.hidden = NO;
        ViewBorderRadius(self.addfriendButton, 4, 0.5, UIColorFromRGB(0xe6e6e6));
        self.addfriendButton.backgroundColor =UIColorFromRGB(0xf87e7e);
        [self.addfriendButton setTitle:@"  添加朋友  " forState:UIControlStateNormal];
    }else if ([[[LTClient sharedClient] contactManager] isFriendWithUserId:userModel.userId])
    {
        self.addfriendButton.hidden = NO;
        ViewBorderRadius(self.addfriendButton, 4, 0.5, UIColorFromRGB(0xe6e6e6));
        self.addfriendButton.backgroundColor =UIColorFromRGB(0xf87e7e);
        [self.addfriendButton setTitle:@"  私聊  " forState:UIControlStateNormal];
    }
    
}








@end
